<?php
header("Access-Control-Allow-Origin:*");
require("../lib/init.php");
require("../pojo/token.php");
$token = $_POST['token'];
$id = $_POST['id'];
$newroleId = $_POST['newroleId'];
$oldroleId = $_POST['oldroleId'];
if (empty($id) or empty($token) or empty($newroleId) or empty($oldroleId)) exit("缺少必要参数");
if (!checkToken($token)) {
    $code = 400;
    $msg = "没有权限";
} else {
    $sql = "update admin set roleId = '$newroleId' where id ='$id'   ";
    if (!MQuery($sql)) {
        $code = 400;
        $msg = "修改失败！";
    } else {
        $code = 200;
        $msg = "修改成功！";
    }
}
echo json_encode(resultmsg($code, $msg));
